#!/usr/bin/python3
# coding=utf-8
#
# Copyright (C) 2023-2025. Huawei Technologies Co., Ltd. All rights reserved.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# ===============================================================================

import numpy as np

# 支持的数据类型映射
dtype_emu = {np.float16: 1, np.float32: 2, np.int8: 3, np.int16: 4, np.int32: 5}

def gen_golden_data_simple():
    # 选择数据类型
    # dtype = np.float16
    dtype = np.float32

    # 定义输入张量形状 [N, C, H, W]
    input_shape = [8, 1, 8, 2048]  # 可以调整这些维度进行测试
    
    # 选择要翻转的维度 (0:N, 1:C, 2:H, 3:W)
    flip_dim = 2

    # 生成随机输入数据
    input_x = np.random.uniform(-10, 10, input_shape).astype(dtype)
    
    # 计算golden结果 - 翻转指定维度
    golden = np.flip(input_x, axis=flip_dim).astype(dtype)

    # 根据新的tiling结构准备数据
    total_elements = np.prod(input_shape)
    
    # 新的tiling结构: totalLength, tileNum, dimN, dimC, dimH, dimW, dim
    tiling_data = [
        total_elements,          # totalLength: 总元素个数
        8,                       # tileNum: 分片数量（这里设为1，表示不分片）
        input_shape[0],          # dimN: N维度
        input_shape[1],          # dimC: C维度  
        input_shape[2],          # dimH: H维度
        input_shape[3],          # dimW: W维度
        flip_dim                 # dim: 翻转维度
    ]
    
    tiling = np.array(tiling_data, dtype=np.int32)  # 注意改为int32类型

    # 保存文件
    tiling.tofile("./input/input_tiling.bin")
    input_x.tofile("./input/input_x.bin")
    golden.tofile("./output/golden.bin")

if __name__ == "__main__":
    gen_golden_data_simple()